package cn.kooki.app.duobao.ui.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.kooki.app.duobao.R;
import cn.kooki.app.duobao.base.BaseFragment;
import cn.kooki.app.duobao.ui.Activity.Share.ShareActivity;
import cn.kooki.app.duobao.ui.Adapter.ShareFragmentAdapter;
import cn.kooki.app.duobao.ui.widget.CustomRelativeLayout;

/**
 * Created by xiong on 2015/11/25.
 */
public class ShareFragment extends BaseFragment {


    @Bind(R.id.top_back)
    ImageButton topBack;
    @Bind(R.id.top_text_center)
    TextView topTextCenter;
    @Bind(R.id.top_cart)
    ImageButton topCart;
    @Bind(R.id.action_edit)
    TextView actionEdit;
    @Bind(R.id.toolbar)
    RelativeLayout toolbar;
    @Bind(R.id.list_view)
    ListView listView;
    @Bind(R.id.loading_wrapper)
    CustomRelativeLayout loadingWrapper;
    private ShareFragmentAdapter shareFragmentAdapter;

    @Override
    public View setView(LayoutInflater inflater, ViewGroup container) {
        View view = inflater.inflate(R.layout.fragment_share, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    private ArrayList<String> datas = new ArrayList<>();

    @Override
    public void afterView() {
        topTextCenter.setText(R.string.tab_find);
        topTextCenter.setVisibility(View.VISIBLE);
        datas.add("djj");
        shareFragmentAdapter = new ShareFragmentAdapter(context, datas);
        listView.setAdapter(shareFragmentAdapter);

        listView.setBackgroundResource(R.color.app_background_highlight);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {
                    intent(ShareActivity.class);
                }
            }
        });
        listView.setVisibility(View.VISIBLE);
//        loadingWrapper.setIswhitle(true);
//        loadingWrapper.showloading();
//        new Handler().postDelayed(new Runnable() {
//            @Override
//            public void run() {
//                loadingWrapper.hideloading();
//                listView.setVisibility(View.VISIBLE);
//            }
//        }, 500);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }


}
